/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.financial.entity.lettercredit;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.base.entity.customer.Customer;
import com.jeesite.modules.base.entity.supplier.Supplier;
import com.jeesite.modules.order.entity.serviceorder.ServiceOrder;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * 信用证Entity
 * @author Kilo
 * @version 2021-03-09
 */
@Table(name="t_letter_credit", alias="a", columns={
		@Column(name="letter_credit_id", attrName="letterCreditId", label="信用证ID", isPK=true),
		@Column(name="letter_credit_code", attrName="letterCreditCode", label="编号"),
		@Column(name="service_order_id", attrName="serviceOrderId", label="服务订单"),
		@Column(name="customer_id", attrName="customer.customerId", label="客户"),
		@Column(name="investor_id", attrName="investorId", label="国内资方"),
		@Column(name="foreign_businessmen_id", attrName="foreignBusinessmenId", label="外商"),
		@Column(name="supplier_address", attrName="supplierAddress", label="供应商地址"),
		@Column(name="supplier_id", attrName="supplierId", label="供货外商"),
		@Column(name="entrust_agreement", attrName="entrustAgreement", label="委托协议"),
		@Column(name="trade_term", attrName="tradeTerm", label="贸易术语"),
		@Column(name="foreign_trade_contract_number", attrName="foreignTradeContractNumber", label="外贸合同号"),
		@Column(includeEntity=DataEntity.class),
		@Column(name="order_status", attrName="orderStatus", label="状态"),
		@Column(name="letter_credit_issuance_date", attrName="letterCreditIssuanceDate", label="信用证开证日"),
		@Column(name="letter_credit_number", attrName="letterCreditNumber", label="信用证号"),
		@Column(name="letter_credit_expiry_date", attrName="letterCreditExpiryDate", label="信用证到期日"),
		@Column(name="ratio", attrName="ratio", label="开证比例"),
		@Column(name="bank", attrName="bank", label="开证银行"),
		@Column(name="total_amount", attrName="totalAmount", label="信用证总金额"),
		@Column(name="payment_method", attrName="paymentMethod", label="付款方式"),
		@Column(name="latest_shipment_date", attrName="latestShipmentDate", label="最晚装船日期"),
		@Column(name="from_port", attrName="fromPort", label="装运港"),
		@Column(name="to_port", attrName="toPort", label="目的港"),
		@Column(name="currency", attrName="currency", label="币种"),
		@Column(name="pre_insured_flag", attrName="preInsuredFlag", label="是否预投保"),
		@Column(name="version", attrName="version", label="版本号"),
	}, joinTable={
		@JoinTable(type=Type.LEFT_JOIN, entity= Customer.class, attrName="customer", alias="c",
				on="c.customer_id = a.customer_id", columns={
				@Column(name="customer_id", label="客户编码", isPK=true),
				@Column(name="customer_name", label="客户名称", isQuery=false),
		}),
		@JoinTable(type=Type.LEFT_JOIN, entity= Supplier.class, attrName="supplier", alias="d",
				on="d.supplier_id = a.supplier_id", columns={
				@Column(name="supplier_id", label="供货外商编码", isPK=true),
				@Column(name="supplier_name", label="供货外商名称", isQuery=false),
		}),
		@JoinTable(type=Type.LEFT_JOIN, entity= Supplier.class, attrName="investor", alias="e",
				on="e.supplier_id = a.investor_id", columns={
				@Column(name="supplier_id", label="国内资方编码", isPK=true),
				@Column(name="supplier_name", label="国内资方名称", isQuery=false),
		}),
		@JoinTable(type=Type.LEFT_JOIN, entity= Supplier.class, attrName="foreignBusinessmen", alias="f",
				on="f.supplier_id = a.foreign_businessmen_id", columns={
				@Column(name="supplier_id", label="外商编码", isPK=true),
				@Column(name="supplier_name", label="外商名称", isQuery=false),
		}),
		@JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = ServiceOrder.class, attrName = "serviceOrder", alias = "s",
				on = "s.service_order_id = a.service_order_id",
				columns = {
						@Column(name = "service_order_id", label = "服务订单ID", isPK = true),
						@Column(name = "service_order_code", label = "服务订单编号"),
		}),
	},orderBy="a.update_date DESC"
)
public class LetterCredit extends DataEntity<LetterCredit> {
	
	private static final long serialVersionUID = 1L;
	private String letterCreditId;		// 信用证ID
	private String letterCreditCode;		// 编号
	private String serviceOrderId;		// 服务订单
	private String customerId;		// 客户
	private String investorId;		// 国内资方
	private String foreignBusinessmenId;		// 外商
	private String supplierAddress;		// 供应商地址
	private String supplierId;		// 供货外商
	private String entrustAgreement;		// 委托协议
	private String tradeTerm;		// 贸易术语
	private String foreignTradeContractNumber;		// 外贸合同号
	private String orderStatus;		// 状态
	private Date letterCreditIssuanceDate;		// 信用证开证日
	private String letterCreditNumber;		// 信用证号
	private Date letterCreditExpiryDate;		// 信用证到期日
	private String ratio;		// 开证比例
	private String bank;		// 开证银行
	private Double totalAmount;		// 信用证总金额
	private String paymentMethod;		// 付款方式
	private Date latestShipmentDate;		// 最晚装船日期
	private String fromPort;		// 装运港
	private String toPort;		// 目的港
	private String currency;		// 币种
	private String preInsuredFlag;		// 是否预投保
	private Long version;		// 版本号
	private List<LetterCreditDetail> letterCreditDetailList = ListUtils.newArrayList();		// 子表列表
	private Customer customer;
	private Supplier supplier;
	private Supplier investor;
	private Supplier foreignBusinessmen;
	private LetterCreditDetail letterCreditDetail;

	public LetterCreditDetail getLetterCreditDetail() {
		return letterCreditDetail;
	}

	public void setLetterCreditDetail(LetterCreditDetail letterCreditDetail) {
		this.letterCreditDetail = letterCreditDetail;
	}

	public ServiceOrder getServiceOrder() {
		return serviceOrder;
	}

	public void setServiceOrder(ServiceOrder serviceOrder) {
		this.serviceOrder = serviceOrder;
	}

	private ServiceOrder serviceOrder;        // 服务订单

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	public Supplier getInvestor() {
		return investor;
	}

	public void setInvestor(Supplier investor) {
		this.investor = investor;
	}

	public Supplier getForeignBusinessmen() {
		return foreignBusinessmen;
	}

	public void setForeignBusinessmen(Supplier foreignBusinessmen) {
		this.foreignBusinessmen = foreignBusinessmen;
	}

	public LetterCredit() {
		this(null);
	}

	public LetterCredit(String id){
		super(id);
	}
	
	public String getLetterCreditId() {
		return letterCreditId;
	}

	public void setLetterCreditId(String letterCreditId) {
		this.letterCreditId = letterCreditId;
	}
	
	@Length(min=0, max=100, message="编号长度不能超过 100 个字符")
	public String getLetterCreditCode() {
		return letterCreditCode;
	}

	public void setLetterCreditCode(String letterCreditCode) {
		this.letterCreditCode = letterCreditCode;
	}
	
	@Length(min=0, max=64, message="服务订单长度不能超过 64 个字符")
	public String getServiceOrderId() {
		return serviceOrderId;
	}

	public void setServiceOrderId(String serviceOrderId) {
		this.serviceOrderId = serviceOrderId;
	}
	
	@Length(min=0, max=64, message="客户长度不能超过 64 个字符")
	public String getCustomerId() {
		return customerId;
	}

	public void setCustomerId(String customerId) {
		this.customerId = customerId;
	}
	
	@Length(min=0, max=64, message="国内资方长度不能超过 64 个字符")
	public String getInvestorId() {
		return investorId;
	}

	public void setInvestorId(String investorId) {
		this.investorId = investorId;
	}
	
	@Length(min=0, max=64, message="外商长度不能超过 64 个字符")
	public String getForeignBusinessmenId() {
		return foreignBusinessmenId;
	}

	public void setForeignBusinessmenId(String foreignBusinessmenId) {
		this.foreignBusinessmenId = foreignBusinessmenId;
	}
	
	@Length(min=0, max=255, message="供应商地址长度不能超过 255 个字符")
	public String getSupplierAddress() {
		return supplierAddress;
	}

	public void setSupplierAddress(String supplierAddress) {
		this.supplierAddress = supplierAddress;
	}
	
	@Length(min=0, max=64, message="供货外商长度不能超过 64 个字符")
	public String getSupplierId() {
		return supplierId;
	}

	public void setSupplierId(String supplierId) {
		this.supplierId = supplierId;
	}
	
	@Length(min=0, max=100, message="委托协议长度不能超过 100 个字符")
	public String getEntrustAgreement() {
		return entrustAgreement;
	}

	public void setEntrustAgreement(String entrustAgreement) {
		this.entrustAgreement = entrustAgreement;
	}
	
	@Length(min=0, max=2, message="贸易术语长度不能超过 2 个字符")
	public String getTradeTerm() {
		return tradeTerm;
	}

	public void setTradeTerm(String tradeTerm) {
		this.tradeTerm = tradeTerm;
	}
	
	@Length(min=0, max=100, message="外贸合同号长度不能超过 100 个字符")
	public String getForeignTradeContractNumber() {
		return foreignTradeContractNumber;
	}

	public void setForeignTradeContractNumber(String foreignTradeContractNumber) {
		this.foreignTradeContractNumber = foreignTradeContractNumber;
	}
	
	@Length(min=0, max=1, message="状态长度不能超过 1 个字符")
	public String getOrderStatus() {
		return orderStatus;
	}

	public void setOrderStatus(String orderStatus) {
		this.orderStatus = orderStatus;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@NotNull(message="信用证开证日不能为空")
	public Date getLetterCreditIssuanceDate() {
		return letterCreditIssuanceDate;
	}

	public void setLetterCreditIssuanceDate(Date letterCreditIssuanceDate) {
		this.letterCreditIssuanceDate = letterCreditIssuanceDate;
	}
	
	@NotBlank(message="信用证号不能为空")
	@Length(min=0, max=100, message="信用证号长度不能超过 100 个字符")
	public String getLetterCreditNumber() {
		return letterCreditNumber;
	}

	public void setLetterCreditNumber(String letterCreditNumber) {
		this.letterCreditNumber = letterCreditNumber;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@NotNull(message="信用证到期日不能为空")
	public Date getLetterCreditExpiryDate() {
		return letterCreditExpiryDate;
	}

	public void setLetterCreditExpiryDate(Date letterCreditExpiryDate) {
		this.letterCreditExpiryDate = letterCreditExpiryDate;
	}
	
	@Length(min=0, max=10, message="开证比例长度不能超过 10 个字符")
	public String getRatio() {
		return ratio;
	}

	public void setRatio(String ratio) {
		this.ratio = ratio;
	}
	
	@NotBlank(message="开证银行不能为空")
	@Length(min=0, max=2, message="开证银行长度不能超过 2 个字符")
	public String getBank() {
		return bank;
	}

	public void setBank(String bank) {
		this.bank = bank;
	}
	
	@NotNull(message="信用证总金额不能为空")
	public Double getTotalAmount() {
		return totalAmount;
	}

	public void setTotalAmount(Double totalAmount) {
		this.totalAmount = totalAmount;
	}
	
	@Length(min=0, max=2, message="付款方式长度不能超过 2 个字符")
	public String getPaymentMethod() {
		return paymentMethod;
	}

	public void setPaymentMethod(String paymentMethod) {
		this.paymentMethod = paymentMethod;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getLatestShipmentDate() {
		return latestShipmentDate;
	}

	public void setLatestShipmentDate(Date latestShipmentDate) {
		this.latestShipmentDate = latestShipmentDate;
	}
	
	@Length(min=0, max=2, message="装运港长度不能超过 2 个字符")
	public String getFromPort() {
		return fromPort;
	}

	public void setFromPort(String fromPort) {
		this.fromPort = fromPort;
	}
	
	@Length(min=0, max=2, message="目的港长度不能超过 2 个字符")
	public String getToPort() {
		return toPort;
	}

	public void setToPort(String toPort) {
		this.toPort = toPort;
	}
	
	@Length(min=0, max=2, message="币种长度不能超过 2 个字符")
	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}
	
	@Length(min=0, max=1, message="是否预投保长度不能超过 1 个字符")
	public String getPreInsuredFlag() {
		return preInsuredFlag;
	}

	public void setPreInsuredFlag(String preInsuredFlag) {
		this.preInsuredFlag = preInsuredFlag;
	}
	
	public Long getVersion() {
		return version;
	}

	public void setVersion(Long version) {
		this.version = version;
	}
	
	public Date getLetterCreditIssuanceDate_gte() {
		return sqlMap.getWhere().getValue("letter_credit_issuance_date", QueryType.GTE);
	}

	public void setLetterCreditIssuanceDate_gte(Date letterCreditIssuanceDate) {
		sqlMap.getWhere().and("letter_credit_issuance_date", QueryType.GTE, letterCreditIssuanceDate);
	}
	
	public Date getLetterCreditIssuanceDate_lte() {
		return sqlMap.getWhere().getValue("letter_credit_issuance_date", QueryType.LTE);
	}

	public void setLetterCreditIssuanceDate_lte(Date letterCreditIssuanceDate) {
		sqlMap.getWhere().and("letter_credit_issuance_date", QueryType.LTE, letterCreditIssuanceDate);
	}
	
	public Date getLetterCreditExpiryDate_gte() {
		return sqlMap.getWhere().getValue("letter_credit_expiry_date", QueryType.GTE);
	}

	public void setLetterCreditExpiryDate_gte(Date letterCreditExpiryDate) {
		sqlMap.getWhere().and("letter_credit_expiry_date", QueryType.GTE, letterCreditExpiryDate);
	}
	
	public Date getLetterCreditExpiryDate_lte() {
		return sqlMap.getWhere().getValue("letter_credit_expiry_date", QueryType.LTE);
	}

	public void setLetterCreditExpiryDate_lte(Date letterCreditExpiryDate) {
		sqlMap.getWhere().and("letter_credit_expiry_date", QueryType.LTE, letterCreditExpiryDate);
	}
	
	public Date getLatestShipmentDate_gte() {
		return sqlMap.getWhere().getValue("latest_shipment_date", QueryType.GTE);
	}

	public void setLatestShipmentDate_gte(Date latestShipmentDate) {
		sqlMap.getWhere().and("latest_shipment_date", QueryType.GTE, latestShipmentDate);
	}
	
	public Date getLatestShipmentDate_lte() {
		return sqlMap.getWhere().getValue("latest_shipment_date", QueryType.LTE);
	}

	public void setLatestShipmentDate_lte(Date latestShipmentDate) {
		sqlMap.getWhere().and("latest_shipment_date", QueryType.LTE, latestShipmentDate);
	}
	
	public Date getCreateDate_gte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.GTE);
	}

	public void setCreateDate_gte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.GTE, createDate);
	}
	
	public Date getCreateDate_lte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.LTE);
	}

	public void setCreateDate_lte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.LTE, createDate);
	}
	
	public List<LetterCreditDetail> getLetterCreditDetailList() {
		return letterCreditDetailList;
	}

	public void setLetterCreditDetailList(List<LetterCreditDetail> letterCreditDetailList) {
		this.letterCreditDetailList = letterCreditDetailList;
	}
	
}